var BASE_URL = 'http://jinzhidata.com/v2'

$(function () {
    // 加载报告/资料 todo 此处一次性加载所有的，待修改
    var url = window.location.href
    var resourceNameLikeMatch = new RegExp(BASE_URL + "/resource_list\\.html\\?searchWord=(.*)").exec(url)
    if (resourceNameLikeMatch) {
        var queryUrl = BASE_URL + "/resource/list/like"
        var queryData = {
            resourceName: decodeURI(resourceNameLikeMatch[1]),
            page: 0,
            size: 999999
        }
    } else {
        var queryUrl = BASE_URL + "/resource/list"
        var queryData = {
            page: 0,
            size: 999999
        }
    }
    $.ajax({
        url: queryUrl,
        data: queryData,
        type: "get",
        contentType: 'application/json',
        dataType: "json",
        success: function (response) {
            var data = response.data
            var html = '';
            for (var i = 0; i < data.length; i++) {
                html += '<li class="list_box">';
                html += '<div class="list_info">'
                html += '<div class="jg_logo">'
                html += '<a href="' + BASE_URL + "/resource.html?resourceId=" + data[i].resourceId + '">'
                html += '<img src="/img/' + data[i].resourceCover + '"/>';
                html += '</a>';
                html += "<dl>";
                html += '<dt><a href="' + BASE_URL + "/resource.html?resourceId=" + data[i].resourceId + '">' + data[i].resourceName + '</a></dt>'
                html += '<dd>积分：<a href="#">' + data[i].resourcePrice + '</a></dd>'
                html += "</dl>";
                html += "</div>";
                html += "</div>";
                html += "</li>";
            }
            $(".school_sc>ul").html(html)
        }
    })
})

